package pattern.singleton;

/**
 * 双重锁
 */
public class Singleton3 {
    // 私有化构造方法
    private Singleton3() {}

    private volatile static Singleton3 singleton3;

    public static Singleton3 getInstance() {
        if (singleton3 == null) {
            synchronized (Singleton3.class) {
                if (singleton3 == null) {
                    singleton3 = new Singleton3();
                }
            }
        }
        return singleton3;
    }
}
